<?php
/**
 * Add a new rail_object to current object's inventory. The name is requested as $_POST['name'] the type of the new rail_object
 * as $_POST['type'].
 *
 * PHP versions 5
 *
 * Copyright (C)
 * This program is free software. You can redistribute it and/or modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation. Either version 2 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY. Without even the implied warranty
 * of ERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with this program. Ff not, write to the Free Software
 * Fundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
 *
 * Copyright (C) 2006-2007
 *
 * @author Bastian Schröder <bs@chemanet.de>
 * @version 2008-04-17
 * @package railbrowser
 */

function ajax_call( $ajaxBridge ) {
	global $rail, $object;

	// try to add an rail_object to current objects inventory
	try{
		switch( $_POST['type'] ){
			case 'rail_container':
				rail_factory::create_container( $rail, $object, $_POST['name'] );
				break;
			case 'rail_document':
				rail_factory::create_document( $rail, $object, $_POST['name'] );
				break;
			case 'rail_group':
				rail_factory::create_group( $rail, $object, $_POST['name'] );
				break;
			case 'rail_link':
				rail_factory::create_link( $rail, $object, $_POST['name'] );
				break;
			case 'rail_sequence':
				rail_factory::create_sequence( $rail, $object, $_POST['name'] );
				break;
			case 'rail_user':
				rail_factory::create_user( $rail, $object, $_POST['name'], uniqid('p_') );
				break;
			default:
				rail_factory::create_object( $rail, $object, $_POST['name'], $_POST['type'] );
		}
	}
	catch( Exception $e ){ $ajaxBridge->register_exception( $e, 3 ); }
}

?>